package com.bjdd.jdy.ui.videoExam;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

import com.bjdd.jdy.R;
import com.bjdd.jdy.base.BaseActivity;
import com.bjdd.jdy.util.L;
import com.bjdd.jdy.util.StatusBarUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class VideoExamActivity extends BaseActivity<VideoExamPresenter, VideoExamModel> implements VideoExamContract.View {


    @Bind(R.id.toolbar_back)
    ImageView toolbarBack;
    @Bind(R.id.title)
    TextView title;
    @Bind(R.id.video_view)
    VideoView videoView;
    private int type;

    @Override
    public int getLayoutId() {
        return R.layout.activity_video_exam;
    }

    @Override
    public void initView() {
        StatusBarUtil.setColor(this,getResources().getColor(R.color.toolbar_bg),0);
        title.setText("在线学习");
        Bundle bundle = getIntent().getExtras();
        type = bundle.getInt("type");
        presenter.getVideoURL(type);
        presenter.commitExam(type);
    }

    @Override
    public void passExam() {
        L.d("通过考试");
    }

    @Override
    public void urlBack(String url) {
        videoView.setVideoPath(url);
        videoView.canPause();
        videoView.canSeekBackward();
        videoView.canSeekForward();
        videoView.setMediaController(new MediaController(this));
        videoView.start();
    }


    @OnClick(R.id.toolbar_back)
    public void onViewClicked() {
        finish();
    }
}
